import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import { viteMockServe } from 'vite-plugin-mock'
import pngToSvg from 'vite-plugin-png-to-svg'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()]
    }),
    Components({
      resolvers: [ElementPlusResolver()]
    }),
    viteMockServe({
      mockPath: './src/mock'
    }),
    pngToSvg({
      //　所有参数为可选
      pngPath: "/src/assets/png", // png图片位置，默认/src/assets/png
      svgPath: "/src/assets/svg", // 生成的svg保存位置，默认/src/assets/svg
      // isReplace: false, // 替换指定文件内容中的png图片，默认false
      // include: ['vue', 'tsx'], // 指定文件后缀，默认['vue','tsx']。isReplace=true时有效
      replaceType: 'img' // 替换模式，img/svg两种。默认img。isReplace=true时有效
    })
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})
